<div class="col-lg-10">
	<h1>Редактировать новости/Удалить новости</h1>
	<hr>
	<?php
			if(isset($_GET['do']))
			{
				if( $_GET['do']=="edit")
				{
				mysql_select_db(DB_NAME) or die(mysql_error());	
				$query1="select id,name,long_description,image from news where id='".$_GET['id']."'";
				$res1 = mysql_query($query1) or die(mysql_error());
				while($news_name = mysql_fetch_array($res1, MYSQL_ASSOC)) {
			echo $news_name["id"];
			echo "<form action=".$_SERVER['PHP_SELF']." method='post' enctype='multipart/form-data'>";
		echo "<div class='form-group'>";
			echo '<label for="news_title">Заголовок новости: </label>';
		echo '	<input type="text" required name="news_title" value="'.$news_name['name'].'" class="form-control">';
			echo '</div>';
echo '	<input type="hidden"   name="id" value="'.$news_name['id'].'"  >';
echo '	<input type="hidden"   name="old_image" value="'.$news_name['image'].'" >';
		echo '<div class="form-group">';
		echo '	<label for="news_desc">Описание новости: </label>';
		echo '	<textarea name="news_desc"  id="news_desc" required cols="30" rows="10" class="form-control">'.$news_name['long_description'].'</textarea>';
		echo '</div>';
		echo "<img src='../images/news/".$news_name["image"]."' height='150px'>";
		echo '<div class="form-group">';
		echo '<label for="news_img">Прикрепить другую картинку: </label>';
		echo '<input type="file"  name="news_img2">';
		echo '</div>';
		echo '<div class="form-group">';
		echo '<input type="submit" name="news_refresh" class="btn btn-lg btn-primary" value="Refresh">';
		echo '</div>';
		echo '</form>';
		}
				}
				else
					{
							if( $_GET['do']=="del")
						{
						mysql_select_db(DB_NAME) or die(mysql_error());	
						$query="delete from news where id='".$_GET['id']."'";
						$res = mysql_query($query) or die(mysql_error());
						echo "You dissmised new with id=".$_GET['id'];
						header("Location: index.php?p=del_news");
						}else{
				
						}
					
					
					
					}
			
			
			}		
						
mysql_select_db(DB_NAME) or die(mysql_error());	
		$rows="SELECT id, name, long_description,date_news,image FROM news";	
		$result=mysql_query($rows) or die(mysql_error());
		echo "<table class='table'><tr><td>id</td><td>name</td><td>description</td><td>date</td><td>image</td><td>edit/del</td></tr>";
			while($news_name=mysql_fetch_array($result)){
					echo "<tr><td>".$news_name["id"]."</td><td>".$news_name["name"]."</td><td>".$news_name["long_description"]."</td><td>".$news_name["date_news"]."</td><td><img src='../images/news/".$news_name["image"]."' height='150px'></td><td><a class='btn btn-success' href='index.php?p=del_news&&do=edit&&id=".$news_name["id"]."'>Edit</a>&nbsp;<a class='btn btn-danger' href='index.php?p=del_news&&do=del&&id=".$news_name["id"]."'>Delete</a></td><tr>"; 
			}
		echo "</table>";
			
			?>
			
			
			
</div>